package com.czl.module_storehouse.activity.intostore.saveloc;

import android.os.Bundle;
import android.view.LayoutInflater;

import com.czl.module_base.activity.BaseActivity;
import com.czl.module_storehouse.databinding.LayoutRecyclerViewBinding;
import com.czl.module_storehouse.R;
import com.czl.module_storehouse.adapter.LocationInfoAdapter;
import com.czl.module_storehouse.bean.StorageSortViewListBean;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;

/**
 * @author xubin
 */
public class LocationInfoActivity extends BaseActivity<LayoutRecyclerViewBinding> {

    private LocationInfoAdapter mAdapter;

    @Override
    protected LayoutRecyclerViewBinding getBinding(LayoutInflater layoutInflater) {
        return LayoutRecyclerViewBinding.inflate(layoutInflater);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        mToolBinding.toolbarContentTitle.setText("存放位置");
        mAdapter = new LocationInfoAdapter(R.layout.item_location_info, new ArrayList<>());
        binding.recyclerView.setAdapter(mAdapter);
        EventBus.getDefault().register(this);
    }

    @Subscribe(threadMode = ThreadMode.POSTING, sticky = true)
    public void onDataEvent(StorageSortViewListBean bean) {
        if (bean == null || mAdapter == null) {
            return;
        }
        mAdapter.addData(bean.getLocatList());
    }

}
